﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Domain;

public partial class m_MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!Utils.isMobile())
            {
                //Response.Redirect("~/default.aspx");
            }

            if (Utils.operadorLogueado == null)
            {
                // error de session
                Response.Redirect(Utils.SecureRedirect("~/m_login.aspx?page=" + 
                                                                this.Request.Url.Segments[2] + 
                                                                (string.IsNullOrEmpty(this.Request.QueryString.ToString()) ? string.Empty : "&" + this.Request.QueryString)));
            }

            if (string.IsNullOrEmpty(Request.QueryString.ToString()) ||   // si no hay querystring
                !QueryStringHash.GetIntegrityCheck(Request.QueryString.ToString())) // o no cumple la verificacion del hash
            {
                Response.Redirect("~/naughty.htm");
                return;
            }

            Usuario u = (Usuario)Utils.operadorLogueado;
            lbl_usr.Text = u.Nombre + " " + u.Apellido;

        }
    }
}
